package com.greystripe.sdk;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ProviderInfo;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

final class bj
{
  private static String a = "com.greystripe.settings.providers";
  private static String b = a + ".SettingsContentProvider";
  private static Map c = new HashMap();
  private static SharedPreferences d;
  private static final Set e;
  private static final Set f;
  private static boolean g = false;
  private static bl h = null;

  static
  {
    e = new HashSet();
    f = new HashSet();
    e.add(bk.GUID);
    f.add(bk.GUID);
    f.add(bk.AD_SERVER_URL);
  }

  static bl a()
  {
    if (h == null)
      h = new bl((byte)0);
    return h;
  }

  static String a(bk parambk)
  {
    return c(parambk.name());
  }

  static void a(Context paramContext)
  {
    if (!g)
    {
      d = paramContext.getSharedPreferences("gs_preferences_" + GSSdkInfo.getVersion(), 0);
      c(paramContext);
      g = true;
    }
  }

  static void a(String paramString)
  {
    a(bk.GUID.name(), paramString);
  }

  static void a(String paramString1, String paramString2)
  {
    if ((paramString2 != null) && (f(paramString1)))
      c.put(paramString1, paramString2);
  }

  static String b()
  {
    return c(bk.GUID.name());
  }

  static void b(String paramString)
  {
    a(bk.AD_SERVER_URL.name(), paramString);
  }

  private static boolean b(Context paramContext)
  {
    try
    {
      ProviderInfo[] arrayOfProviderInfo = paramContext.getPackageManager().getPackageInfo(a, 8).providers;
      boolean bool1 = false;
      int i;
      if (arrayOfProviderInfo != null)
        i = arrayOfProviderInfo.length;
      for (int j = 0; ; j++)
      {
        bool1 = false;
        if (j < i)
        {
          boolean bool2 = arrayOfProviderInfo[j].authority.equals(b);
          if (bool2)
            bool1 = true;
        }
        else
        {
          return bool1;
        }
      }
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
    }
    return false;
  }

  static boolean b(bk parambk)
  {
    return d(parambk.name());
  }

  static String c()
  {
    return c(bk.AD_SERVER_URL.name());
  }

  static String c(String paramString)
  {
    if (c.containsKey(paramString))
      return (String)c.get(paramString);
    return d.getString(paramString, null);
  }

  // ERROR //
  private static void c(Context paramContext)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokestatic 165	com/greystripe/sdk/bj:b	(Landroid/content/Context;)Z
    //   4: ifne +4 -> 8
    //   7: return
    //   8: iconst_3
    //   9: anewarray 144	java/lang/String
    //   12: dup
    //   13: iconst_0
    //   14: ldc 167
    //   16: aastore
    //   17: dup
    //   18: iconst_1
    //   19: ldc 169
    //   21: aastore
    //   22: dup
    //   23: iconst_2
    //   24: ldc 171
    //   26: aastore
    //   27: astore_1
    //   28: new 26	java/lang/StringBuilder
    //   31: dup
    //   32: ldc 173
    //   34: invokespecial 91	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   37: getstatic 41	com/greystripe/sdk/bj:b	Ljava/lang/String;
    //   40: invokevirtual 33	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   43: ldc 175
    //   45: invokevirtual 33	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   48: invokevirtual 39	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   51: invokestatic 181	android/net/Uri:parse	(Ljava/lang/String;)Landroid/net/Uri;
    //   54: astore 4
    //   56: aload_0
    //   57: invokevirtual 185	android/content/Context:getContentResolver	()Landroid/content/ContentResolver;
    //   60: aload 4
    //   62: aload_1
    //   63: aconst_null
    //   64: aconst_null
    //   65: aconst_null
    //   66: invokevirtual 191	android/content/ContentResolver:query	(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    //   69: astore 5
    //   71: aload 5
    //   73: astore_3
    //   74: aload_3
    //   75: ifnonnull +14 -> 89
    //   78: aload_3
    //   79: ifnull -72 -> 7
    //   82: aload_3
    //   83: invokeinterface 196 1 0
    //   88: return
    //   89: aload_3
    //   90: invokeinterface 200 1 0
    //   95: ifeq +71 -> 166
    //   98: aload_3
    //   99: ldc 169
    //   101: invokeinterface 204 2 0
    //   106: istore 6
    //   108: aload_3
    //   109: ldc 171
    //   111: invokeinterface 204 2 0
    //   116: istore 7
    //   118: aload_3
    //   119: iload 6
    //   121: invokeinterface 207 2 0
    //   126: astore 8
    //   128: aload_3
    //   129: iload 7
    //   131: invokeinterface 207 2 0
    //   136: astore 9
    //   138: aload 8
    //   140: invokestatic 209	com/greystripe/sdk/bj:g	(Ljava/lang/String;)Z
    //   143: ifeq +10 -> 153
    //   146: aload 8
    //   148: aload 9
    //   150: invokestatic 109	com/greystripe/sdk/bj:a	(Ljava/lang/String;Ljava/lang/String;)V
    //   153: aload_3
    //   154: invokeinterface 212 1 0
    //   159: istore 10
    //   161: iload 10
    //   163: ifne -45 -> 118
    //   166: aload_3
    //   167: ifnull -160 -> 7
    //   170: aload_3
    //   171: invokeinterface 196 1 0
    //   176: return
    //   177: astore_2
    //   178: aconst_null
    //   179: astore_3
    //   180: aload_3
    //   181: ifnull +9 -> 190
    //   184: aload_3
    //   185: invokeinterface 196 1 0
    //   190: aload_2
    //   191: athrow
    //   192: astore_2
    //   193: goto -13 -> 180
    //
    // Exception table:
    //   from	to	target	type
    //   28	71	177	finally
    //   89	118	192	finally
    //   118	153	192	finally
    //   153	161	192	finally
  }

  static long d()
  {
    return e(bk.AD_READY_TIME.name());
  }

  static boolean d(String paramString)
  {
    return (c.containsKey(paramString)) || (d.contains(paramString));
  }

  static long e()
  {
    return e(bk.AD_LOAD_TIME.name());
  }

  private static long e(String paramString)
  {
    String str = c(paramString);
    if (str == null)
      return 30000L;
    return Long.parseLong(str);
  }

  static void f()
  {
    a(bk.STOP_REQUESTING_ADS_ALWAYS_AND_FOREVER.name(), "true");
    String str = bk.STOP_REQUESTING_ADS_ALWAYS_AND_FOREVER.name();
    if (c.containsKey(str))
    {
      d.edit().putString(str, (String)c.get(str)).commit();
      c.remove(str);
    }
  }

  private static boolean f(String paramString)
  {
    try
    {
      bk localbk = bk.valueOf(paramString);
      if (e.contains(localbk))
      {
        boolean bool = d(localbk.name());
        if (bool)
          return false;
      }
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
    }
    return true;
  }

  static boolean g()
  {
    return d(bk.STOP_REQUESTING_ADS_ALWAYS_AND_FOREVER.name());
  }

  private static boolean g(String paramString)
  {
    try
    {
      bk localbk = bk.valueOf(paramString);
      boolean bool = f.contains(localbk);
      if (bool)
        return false;
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
    }
    return f(paramString);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.greystripe.sdk.bj
 * JD-Core Version:    0.6.2
 */